package com.rx.service;

import java.util.List;

import com.rx.dao.AdminDaoI;
import com.rx.dao.AdminDaoImpl;
import com.rx.entity.Admin;

/**
 * 
 * @类名: AdminServiceImpl
 * @描述: 业务层实现类，会调用dao层方法
 * @作者：侯建军
 * @日期：2018年6月24日 上午9:05:38
 *
 */
public class AdminServiceImpl implements AdminServiceI<Admin> {
	private static AdminDaoI adi = new AdminDaoImpl();

	@Override
	public boolean login(String admin, String password) throws Exception {
		String whereSql = " and admin='" + admin + "' and password='" + password + "'";
		List<Admin> list = adi.selectWhere(whereSql);
		if (list.size() > 0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean resetPWD(Admin admin) {
		return false;
	}

	@Override
	public boolean add(Admin admin) throws Exception {
		List<Admin> list = adi.selectWhere(" and admin='" + admin.getAdmin() + "'");
		if (list.size() > 0) {
			return false;	
		}
		return adi.insert(admin);
	}

	@Override
	public boolean modify(Admin admin) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean remove(int id) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public List<Admin> getAll() throws Exception {
		
		return adi.selectAll();
	}

}
